package org.soft.carbon_neutral.controller;

import com.alibaba.fastjson.JSON;
import org.soft.carbon_neutral.service.EnergyConsumptionService;
import org.soft.carbon_neutral.service.impl.EnergyConsumptionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/energyConsumption")
@CrossOrigin
public class EnergyConsumptionController {

    @Autowired
    private EnergyConsumptionServiceImpl energyConsumptionService;

    @GetMapping("/getConsumptionList")
    public String getConsumptionList() {
        return JSON.toJSONString(energyConsumptionService.getConsumptionList());
    }
}
